import { getEmployeeName, getTimestamp } from '@/utils';
import dayjs from 'dayjs';
import React from 'react';

export const yuanGongLie = (yuanGongs: any, initId: any = null, hideInTable = false) => {
  console.log('initId: ', initId);
  return {
    title: '员工',
    dataIndex: 'yuanGongId',
    valueEnum: yuanGongs,
    initialValue: initId || null,
    fieldProps: { allowClear: false },
    hideInTable: { hideInTable },
    render: (text: any, record: any) => <>{getEmployeeName(yuanGongs, record.text)}</>,
  };
};

export const createTimeLie = (hideInTable = false) => ({
  title: '创建时间',
  dataIndex: 'create_time',
  valueType: 'dateRange',
  hideInTable: { hideInTable },
  search: {
    transform: (val: any) => ({
      from: val ? getTimestamp(`${val[0]} 00:00:00`) : null,
      to: val ? getTimestamp(`${val[1]} 23:59:59`) : null,
    }),
  },
  render: (text: any, record: any) => (
    <>{dayjs(record.createTime * 1000).format('YYYY-MM-DD HH:mm:ss')}</>
  ),
});
